package com.example.android.analytics;

import android.app.Activity;
import android.os.Bundle;
import android.view.View;
import android.widget.TextView;
import com.google.android.apps.analytics.GoogleAnalyticsTracker;

public class SecondActivity extends Activity {

  private GoogleAnalyticsTracker tracker;
  private TextView purchaseConfirmation;

  @Override
  public void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);

    tracker = GoogleAnalyticsTracker.getInstance();

    setContentView(R.layout.secondactivity);
    purchaseConfirmation = (TextView) findViewById(R.id.purchaseConfirmation);
  }

  public void onResume() {
    tracker.trackPageView("/SecondActivity");
    super.onResume();
  }

  public void buyDandyHatPressed(View v) {
    purchaseConfirmation.setText("My, that's a dandy hat!");
    tracker.trackEvent("SecondActivity", "boughtHat", "dandyHat", 10);
  }

  public void buyDapperHatPressed(View v) {
    purchaseConfirmation.setText("Wow, someone looks dapper!");
    tracker.trackEvent("SecondActivity", "boughtHat", "dapperHat", 20);
  }

  public void buyWizardHatPressed(View v) {
    purchaseConfirmation.setText("Accio hat!");
    tracker.trackEvent("SecondActivity", "boughtHat", "wizardHat", 0);
  }
}
